import { detailConfig, dictcodes } from '@/views/datacenter/basicData/oldman/config'

export const formConfig = {
	inline: false,
	showBtn: true,
	labelPosition: 'right',
	labelWidth: '120px',
	column: [
		{
			label: '姓名',
			prop: 'name',
			type: 'remoteSelect',
			api: 'view_dpServiceObject_page',
			filterKey: 'name',
			filterLabel: 'name',
			multiple: false,
			rules: [{ required: true, message: '请选择老人' }],
			span: 12,
			change: (item, form, value) => {
				form.idCard = item.idCard
				form.address = item.crAddress
				form.phone = item.contactPhone
			},
		},
		{
			label: '身份证号码',
			prop: 'idCard',
			type: 'text',
			span: 12,
			rules: [{ required: true, message: '请输入身份证号码' }],
		},
		{
			label: '家庭地址',
			prop: 'address',
			type: 'text',
			span: 12,
			rules: [{ required: true, message: '请输入家庭地址' }],
		},
		{
			label: '家属电话',
			prop: 'phone',
			type: 'text',
			span: 12,
			rules: [{ required: true, message: '请输入家属电话' }],
		},
		{
			label: '喘息开始时间',
			prop: 'pantStartTime',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			type: 'date',
			span: 12,
			rules: [{ required: true, message: '请选择日期' }],
		},
		{
			label: '喘息结束时间',
			prop: 'pantEndTime',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			type: 'date',
			span: 12,
			rules: [{ required: true, message: '请选择日期' }],
		},
	],
}

export const editFormConfig = {
	inline: false,
	showBtn: true,
	labelPosition: 'top',
	labelWidth: '120px',
	column: [
		{
			label: '备注',
			prop: 'note',
			type: 'textarea',
			span: 24,
		},
	],
}

export const searchConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '姓名',
			prop: 'name',
			type: 'input',
			span: 8,
		},
		{
			label: '身份证号码',
			prop: 'idCard',
			type: 'input',
			span: 8,
		},
	],
}

export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		{
			label: '姓名',
			prop: 'name',
		},
		{ label: '证件号码', prop: 'idCard', plusXing: '2,2' },
		{ label: '家属电话', prop: 'phone', plusXing: '5,2' },
		{ label: '家庭地址', prop: 'address' },
		{ label: '申请月', prop: 'month' },
		{ label: '喘息开始时间', prop: 'pantStartTime' },
		{ label: '喘息结束时间', prop: 'pantEndTime' },
		{
			label: '数据来源',
			prop: 'fromSource',
			custome: 'tag',
			dicData: [
				{
					label: '手动添加',
					value: 1,
					type: 'success',
				},
				{
					label: '系统抓取',
					value: 0,
					type: 'primary',
				},
			],
		},
		{
			label: '操作',
			prop: 'menu',
			width: 220,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_serviceObjectPantStatistics_page',
	add: 'view_serviceObjectPantStatistics_add',
	edit: 'view_serviceObjectPantStatistics_edit',
	delete: 'view_serviceObjectPantStatistics_del',
}
export const auth = {
	...api,
	mulitSet: 'mulitSet',
}
export const baseConfig = {
	pageName: '喘息名单',
	dictcodes: dictcodes,
	rowKey: 'id',
	addLabel: '增加',
	tipLabel: 'name',
	exportMqTopic: '/ning/export/',
	api,
	auth,
	menuDefault: [
		{
			icon: 'detail',
			label: '查看档案',
			type: 'primary',
			operate: 'Archives',
			auth: auth.index,
			text: true,
			show: true,
		},
	],
	menuBtn: [
		{
			icon: 'delete',
			label: '删除',
			type: 'danger',
			operate: 'delete',
			auth: auth.delete,
			text: true,
			show: true,
		},
		{
			icon: 'detail',
			label: '查看档案',
			type: 'primary',
			operate: 'Archives',
			auth: auth.index,
			text: true,
			show: true,
		},
	],

	saveFormate: async (form) => {
		return new Promise((resolve, reject) => {
			resolve({
				...form,
				fromSource: 1,
			})
		})
	},
	beforeOnLoadFormate: async (query) => {
		return new Promise((resolve, reject) => {
			resolve(query)
		})
	},
	onLoadFormate: async (arr) => {
		return new Promise((resolve, reject) => {
			resolve(arr)
		})
	},
	dialogConfig: {
		width: '65%',
	},
	detailConfig: {
		customeHeader: {
			...detailConfig.customeHeader,
			menuBtn: [],
		},
	},
	searchConfig,
	formConfig,
	tableConfig,
}
